package com.gdut.demo5;

import com.gdut.demo3.Student;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

public class Demo5 {
    public static void main(String[] args) {
        Set<String> s = new HashSet<>();
        System.out.println(s.add("123"));
        System.out.println(s.add("123"));
        s.add("12");
        s.add("121");
        s.add("125");
        System.out.println(s);
        System.out.println("--------------------");
        HashSet<Student> s2 = new HashSet<>();
        Student std1 = new Student("zhangSan", "010");
        Student std2 = new Student("zhangSan", "010");
        System.out.println(s2.add(std1));
        System.out.println(s2.add(std2));
        System.out.println(std1.hashCode());
        System.out.println(std2.hashCode());
        System.out.println(s2);
        s2.forEach(System.out::println);
        System.out.println("--------------------");
        LinkedHashSet<Student> ls = new LinkedHashSet<>();
        Student std3 = new Student("liSi", "0101");
        Student std4 = new Student("wangWu", "0102");
        ls.add(std1);
        ls.add(std2);
        ls.add(std3);
        ls.add(std4);
        System.out.println(ls);
    }
}
